package com.itheima.a01mybytestream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class ByteStreamDemo1 {
    public static void main(String[] args) throws IOException {
        //拷贝

        //统计拷贝时间
        long start = System.currentTimeMillis();

        //先读在写
        FileInputStream fis = new FileInputStream("D:\\Java\\a.txt");
        FileOutputStream fos = new FileOutputStream("myio\\a.txt");

        //循环读取并写入
        int b;
        while ((b = fis.read()) != -1) {
            //写入
            fos.write(b);
        }

        //释放资源，注意先开的后关
        fos.close();
        fis.close();

        //结束时间
        long end = System.currentTimeMillis();

        System.out.println(end - start);

    }
}
